﻿using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QbservableHubTests
{
    /// <summary>
    /// provide custom convention
    /// </summary>
    public class CustomContractResolver : DefaultContractResolver
    {
        #region ResolvePropertyName

        /// <summary>
        /// Resolves the name of the property.
        /// Used for custom properties naming convention
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns>
        /// Name of the property.
        /// </returns>
        protected override string ResolvePropertyName(string propertyName)
        {
            var convertedPropertyName = base.ResolvePropertyName(propertyName);
            switch (convertedPropertyName)
            {
                case "MethodName":
                    convertedPropertyName = "Mtd";
                    break;
                case "$type":
                    convertedPropertyName = "Type";
                    break;
                case "Instance":
                    convertedPropertyName = "Inst";
                    break;
                case "Arguments":
                    convertedPropertyName = "Arg";
                    break;
            }

            return convertedPropertyName;
        }

        #endregion // ResolvePropertyName
    }
}
